﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace EasyBuildingCMS.BLL.CoreEngine
{

    public class BuildingBlockRepository : CoreEngineBaseRepository
    {
        public BuildingBlockRepository()
        {
            CacheKey += "_BuildingBlock";
        }

        public List<BuildingBlock> GetAcitveBuildingBlock()
        {
            string key = CacheKey + "_Active";

            if (EnableCaching && Cache[key] != null)
            {
                return (List<BuildingBlock>)Cache[key];
            }

            this.CoreEngineContext.MasterPage.MergeOption = MergeOption.NoTracking;

            List<BuildingBlock> buildingBlocks = (from buildBlock  in CoreEngineContext.BuildingBlocks
                                      where buildBlock.Active
                                      select buildBlock).ToList();

            if (EnableCaching)
            {
                CacheData(key, buildingBlocks, CacheDuration);
            }

            return buildingBlocks;
        }


    }

}
